<?php
namespace app\common\model;

class Member extends \think\Model
{
    /** 封装一个用户对象 */
    public function fillMember($id, $name, $avatar, $sc, $openid, $status, $signupon, $token, $acctoken, $expireon)
    {
        $model = [
            'uid' => $id, 'name' => $name, 'avatar' => $avatar, 'source' => $sc, 'openid' => $openid,
            'status' => $status, 'singupData' => $signupon, 'token' => $token, 'accToken' => $acctoken, 'expireOn' => $expireon
        ];

        return $model;
    }
    /** 获取用户基本信息 */
    public function getMemberInfo($id)
    {
        $model = $this->fillMember($id, 'Momo', 'https://wx.qq.com/afdsafdsfds', 'wx', 'o123213211_fdafdsa', 1, '2017-06-27 12:00:01', str_repeat('-', '', uniqid()), '', date('yyyy-MM-dd HH:mm:ss'));
        return $model;
    }
    /** 获取用户列表 */
    public function getMemberList($keyword, $bof, $eof, $take, $pages)
    {
        $lst = array();

        array_push($lst, $this->getMemberInfo(uniqid()));
        array_push($lst, $this->getMemberInfo(uniqid()));
        array_push($lst, $this->getMemberInfo(uniqid()));

        return $lst;
    }
    /** 通过openid第三方登录 */
    public function memberSign($sc, $openid)
    {
        $model = $this->fillMember($id, 'Momo', 'https://wx.qq.com/afdsafdsfds', 'wx', 'o123213211_fdafdsa', 1, '2017-06-27 12:00:01', '', date('yyyy-MM-dd HH:mm:ss'));
        return $model;
    }
    public function autoSign($token)
    {
        $model = $this->fillMember($id, 'Momo', 'https://wx.qq.com/afdsafdsfds', 'wx', 'o123213211_fdafdsa', 1, '2017-06-27 12:00:01', '', date('yyyy-MM-dd HH:mm:ss'));
        return $model;
    }

    /** 创建一个网站用户 */
    public function createMember($model)
    {
        return ['flag' => \FALSE, 'msg' => '此方法未实现'];
    }
    /** 修改网站用户 */
    public function updateMember($id, $model)
    {
        return ['flag' => \FALSE, 'msg' => '此方法未实现'];
    }
    /** 冻结一个网站用户 */
    public function freezeMember($id)
    {
        return ['flag' => \FALSE, 'msg' => '此方法未实现'];
    }

    /** 以下是用户分组  */

    /** 封装一个用户组对象 */
    public function fullMemberGroup($id, $name, $status)
    {
        $model = ['gid' => $id, 'groupName' => $name, 'status' => $status];
        return $model;
    }
    /** 获取用户组信息 */
    public function getGroupInfo($id)
    {
        $model = $this->fillMemberGroup($id, '测试组', 1);
        return $model;
    }
    /** 获取一批用户组 */
    public function getGroupList($keyword, $status, $take, $pages)
    {
        $lst = array();

        array_push($lst, $this->getGroupInfo(1));
        array_push($lst, $this->getGroupInfo(2));
        array_push($lst, $this->getGroupInfo(3));

        return $lst;
    }
    /** 创建一个用户分组 */
    public function createGroup($model)
    {
        return ['flag' => \FALSE, 'msg' => '此方法未实现'];
    }
    /** 修改用户分组 */
    public function updateGroup($id, $model)
    {
        return ['flag' => \FALSE, 'msg' => '此方法未实现'];
    }
    /** 删除一个用户分组 */
    public function removeGroup($id)
    {
        return ['flag' => \FALSE, 'msg' => '此方法未实现'];
    }

}